When Is a Container a Comonad?

نویسندگان

  • Danel Ahman
  • James Chapman
  • Tarmo Uustalu
چکیده

Abbott, Altenkirch, Ghani and others have taught us that many parameterized datatypes (set functors) can be usefully analyzed via container representations in terms of a set of shapes and a set of positions in each shape. This paper builds on the observation that datatypes often carry additional structure that containers alone do not account for. We introduce directed containers to capture the common situation where every position in a datastructure determines another datastructure, informally, the sub-datastructure rooted by that position. Some natural examples are non-empty lists and node-labelled trees, and datastructures with a designated position (zippers). While containers denote set functors via a fully-faithful functor, directed containers interpret fully-faithfully into comonads. But more is true: every comonad whose underlying functor is a container is represented by a directed container. In fact, directed containers are the same as containers that are comonads. We also describe some constructions of directed containers. We have formalized our development in the dependently typed programming language Agda.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Directed Containers as Categories

Directed containers make explicit the additional structure of those containers whose set functor interpretation carries a comonad structure. The data and laws of a directed container resemble those of a monoid, while the data and laws of a directed container morphism those of a monoid morphism in the reverse direction. With some reorganization, a directed container is the same as a small catego...

متن کامل

Scheduling Single-Load and Multi-Load AGVs in Container Terminals

In this paper, three solutions for scheduling problem of the Single-Load and Multi-Load Automated Guided Vehicles (AGVs) in Container Terminals are proposed. The problem is formulated as Constraint Satisfaction and Optimization. When capacity of the vehicles is one container, the problem is a minimum cost flow model. This model is solved by the highest performance Algorithm, i.e. Network Simple...

متن کامل

Distributive Laws of Directed Containers

Containers [1] are an elegant representation of a wide class of datatypes in terms of shapes and positions in shapes. In our FoSSaCS 2012 work [2], we introduced directed containers as a special case to account for the common situation where every position in a shape determines another shape, informally the subshape rooted by that position; some examples being the datatypes of nonempty lists an...

متن کامل

Update Monads: Cointerpreting Directed Containers

Containers are a neat representation of a wide class of set functors. We have previously [1] introduced directed containers as a concise representation of comonad structures on such functors. Here we examine interpreting the opposite categories of containers and directed containers. We arrive at a new view of a di↵erent (considerably narrower) class of set functors and monads on them, which we ...

متن کامل

Should I use a Monad or a Comonad ?

The category theoretic structures of monads and comonads can be used as an abstraction mechanism for simplifying both language semantics and programs. Monads have been used to structure impure computations, whilst comonads have been used to structure context-dependent computations. Interestingly, the class of computations structured by monads and the class of computations structured by comonads...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Logical Methods in Computer Science

دوره 10  شماره 

صفحات  -

تاریخ انتشار 2012